
import CurriculumModel from "@/models/CurriculumModel";

export default class CurriculumService{
    /**
     * 更新课程
     * @param id 课程id
     * @param params
     */
    public static update(id:number|string,params?:object):Promise<any>{
       return  CurriculumModel.update({...params},{where:{id:id}})
    }
    /**
     * 获取课程列表
     */
    public static get(params?:any ):Promise<CurriculumModel[]|CurriculumModel|null> {
        console.log("params=======",params)
        if (params&&params.id){
            const id=params.id
            return CurriculumModel.findOne({where:{id}})
        }
        else {
            return CurriculumModel.findAll()
        }

    }

    /**
     * 删除课程
     * @param id
     */
    public static delete(id:string|number|undefined):Promise<number>{
        return CurriculumModel.destroy({
            where:{
                id
            }
        })
    }
    /**
     * 新建课程
     * @param user
     */
    public static create(user: object) :Promise<CurriculumModel> {
        return CurriculumModel.create( {...user})
    }

}